package com.efast.cafe.framework.vo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class TreeVo implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6443111843659167091L;
	private String id;	
	private String text;
	
	private String icon;
	private String url;
	
	private String parentId;
	
	private List<TreeVo> menus = new ArrayList<TreeVo>();
	
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	private boolean leaf;
	
	
	public boolean isLeaf() {
		return leaf;
	}
	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
	public void removeNoRight(){
    	int size=menus.size();
    	TreeVo node;
    	for(int i=size-1;i>=0;i--){
    		node=menus.get(i);
    		node.removeNoRight();
    		if((!node.isLeaf())&&node.getMenus().size()==0)
    		{	 
    			menus.remove(i);
    		}
    	}
    }
	
	
	public List<TreeVo> getMenus() {
		return menus;
	}
	public void setMenus(List<TreeVo> menus) {
		this.menus = menus;
	}
	public String getId() {
		return this.id;
	}
	
	public String getText() {
		return this.text;
	}
	
	
	public void setText(String text) {
		this.text = text;
	}
	public void setId(String id) {
		this.id = id;
	}
   
	
    public void removeById(String nodeId){
    	int size=menus.size();
    	TreeVo node;
    	for(int i=size-1;i>=0;i--){
    		node=menus.get(i);
    		node.removeById(nodeId);
    		if(node.getId().equals(nodeId))
    		{	 
    			menus.remove(i);
    		}
    	}
    }
	public String getParentId() {
		return parentId;
	}
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}
	
    
    
}
